<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式系统中的负载均衡策略</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* Hero Section Styles */
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-pattern {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
        }
        
        /* Typography */
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* Card Styles */
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 1rem;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.15), 0 15px 15px -5px rgba(0, 0, 0, 0.06);
        }
        
        /* Section Headers */
        .section-header {
            position: relative;
            padding-left: 1.5rem;
            margin-bottom: 2rem;
        }
        
        .section-header::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        /* Feature Cards */
        .feature-card {
            background: linear-gradient(135deg, #f5f7fa 0%, #ffffff 100%);
            border: 1px solid rgba(102, 126, 234, 0.1);
            transition: all 0.3s ease;
        }
        
        .feature-card:hover {
            border-color: rgba(102, 126, 234, 0.3);
            transform: translateY(-4px);
            box-shadow: 0 12px 24px -10px rgba(102, 126, 234, 0.3);
        }
        
        /* Algorithm Cards */
        .algorithm-card {
            background: white;
            border-left: 4px solid transparent;
            transition: all 0.3s ease;
        }
        
        .algorithm-card:hover {
            border-left-color: #667eea;
            box-shadow: 0 10px 20px -10px rgba(102, 126, 234, 0.4);
        }
        
        /* Mermaid Container */
        .mermaid-container {
            background: #f8fafc;
            border-radius: 0.75rem;
            padding: 2rem;
            margin: 2rem 0;
            box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
        }
        
        /* Smooth Scroll */
        html {
            scroll-behavior: smooth;
        }
        
        /* Navigation Dots */
        .nav-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: rgba(102, 126, 234, 0.3);
            transition: all 0.3s ease;
            cursor: pointer;
        }
        
        .nav-dot.active {
            background: #667eea;
            transform: scale(1.2);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 relative">
        <div class="hero-pattern"></div>
        <div class="container mx-auto px-6 relative z-10">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight">
                    分布式系统中的<br>负载均衡策略
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90 font-light">
                    探索现代分布式架构中的流量分发艺术
                </p>
                <div class="flex justify-center space-x-4">
                    <div class="bg-white bg-opacity-20 backdrop-filter backdrop-blur-lg rounded-lg px-6 py-3">
                        <i class="fas fa-server mr-2"></i>
                        <span>高可用架构</span>
                    </div>
                    <div class="bg-white bg-opacity-20 backdrop-filter backdrop-blur-lg rounded-lg px-6 py-3">
                        <i class="fas fa-chart-line mr-2"></i>
                        <span>性能优化</span>
                    </div>
                    <div class="bg-white bg-opacity-20 backdrop-filter backdrop-blur-lg rounded-lg px-6 py-3">
                        <i class="fas fa-shield-alt mr-2"></i>
                        <span>智能调度</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Navigation -->
    <nav class="sticky top-0 bg-white shadow-md z-50">
        <div class="container mx-auto px-6">
            <div class="flex items-center justify-between py-4">
                <div class="flex items-center space-x-8">
                    <a href="#overview" class="text-gray-700 hover:text-purple-600 transition">概述</a>
                    <a href="#algorithms" class="text-gray-700 hover:text-purple-600 transition">算法</a>
                    <a href="#implementation" class="text-gray-700 hover:text-purple-600 transition">实现</a>
                    <a href="#selection" class="text-gray-700 hover:text-purple-600 transition">选择</a>
                    <a href="#dynamic" class="text-gray-700 hover:text-purple-600 transition">动态调整</a>
                    <a href="#advanced" class="text-gray-700 hover:text-purple-600 transition">高级策略</a>
                </div>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="content-card p-8 mb-12">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">在</span>分布式系统的架构设计中，负载均衡是一项至关重要的技术，它直接影响到系统的性能、可靠性和可扩展性。想象一下，如果一组服务器中的某些实例负载过高，而其他实例却处于空闲状态，这不仅浪费了资源，还可能导致高负载服务器响应变慢甚至宕机，从而影响用户体验。因此，为了实现分布式系统中的资源合理分配，我们需要通过负载均衡将请求流量智能地分发到多个服务器实例，确保整个系统的高效运行。
            </p>
            
            <div class="mermaid-container mt-8">
                <div id="system-overview" class="mermaid">
                    graph TB
                        Client[客户端请求] --> LB[负载均衡器]
                        LB --> S1[服务器1]
                        LB --> S2[服务器2]
                        LB --> S3[服务器3]
                        LB --> S4[服务器4]
                        
                        style Client fill:#f9f,stroke:#333,stroke-width:2px
                        style LB fill:#667eea,stroke:#333,stroke-width:2px,color:#fff
                        style S1 fill:#9f7aea,stroke:#333,stroke-width:2px,color:#fff
                        style S2 fill:#9f7aea,stroke:#333,stroke-width:2px,color:#fff
                        style S3 fill:#9f7aea,stroke:#333,stroke-width:2px,color:#fff
                        style S4 fill:#9f7aea,stroke:#333,stroke-width:2px,color:#fff
                </div>
            </div>
            
            <p class="text-lg leading-relaxed text-gray-700 mt-6">
                负载均衡并不是一个单一的技术，而是结合了多种算法、策略和实现方式来应对不同的业务场景。例如，最简单的轮询分发适用于相对均匀的负载环境，而一致性哈希则常用于缓存系统和分布式存储中以确保数据的定位稳定性。此外，随着云计算和微服务架构的兴起，负载均衡也逐步从硬件层迁移到软件层，甚至被深度集成到服务注册与发现中，例如Nginx、HAProxy和Kubernetes中的Service Mesh。
            </p>
        </div>

        <!-- Overview Section -->
        <section id="overview" class="mb-16">
            <div class="section-header">
                <h2 class="text-3xl font-bold text-gray-800">负载均衡的概述</h2>
            </div>
            
            <div class="content-card p-8">
                <p class="text-lg leading-relaxed text-gray-700 mb-8">
                    负载均衡（Load Balancing）是分布式系统中一种关键技术，用于在多个服务器或服务实例之间合理分配请求流量，以确保系统的高效运行、资源的充分利用以及用户请求的快速响应。负载均衡既是分布式架构中常见的需求，也是提升系统性能和可靠性的重要手段。
                </p>
                
                <div class="grid md:grid-cols-3 gap-6 mb-8">
                    <div class="feature-card p-6 rounded-lg text-center">
                        <div class="text-4xl text-purple-600 mb-4">
                            <i class="fas fa-tachometer-alt"></i>
                        </div>
                        <h4 class="text-xl font-semibold mb-2">性能优化</h4>
                        <p class="text-gray-600">合理分配流量，避免某些服务器过载，提升系统整体的吞吐量和响应速度</p>
                    </div>
                    
                    <div class="feature-card p-6 rounded-lg text-center">
                        <div class="text-4xl text-purple-600 mb-4">
                            <i class="fas fa-shield-alt"></i>
                        </div>
                        <h4 class="text-xl font-semibold mb-2">高可用性</h4>
                        <p class="text-gray-600">当服务实例出现故障时，将流量引导至健康实例，保障服务的连续性</p>
                    </div>
                    
                    <div class="feature-card p-6 rounded-lg text-center">
                        <div class="text-4xl text-purple-600 mb-4">
                            <i class="fas fa-expand-arrows-alt"></i>
                        </div>
                        <h4 class="text-xl font-semibold mb-2">可扩展性</h4>
                        <p class="text-gray-600">支持系统横向扩展，通过动态调整服务实例数量来应对流量波动</p>
                    </div>
                </div>
                
                <div class="bg-gray-50 rounded-lg p-6">
                    <h4 class="text-xl font-semibold mb-4 text-gray-800">
                        <i class="fas fa-layer-group mr-2 text-purple-600"></i>
                        负载均衡的层级
                    </h4>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <span class="inline-block w-8 h-8 bg-purple-600 text-white rounded-full text-center leading-8 mr-3 flex-shrink-0">1</span